package org.zhadoop.streaming.exception;

/**
 * Streaming运行时异常
 * 所有的运行时异常，都继承自该类，或者直接抛出该类
 * 
 * @author zwd
 *
 */
public class StreamingRuntimeException extends RuntimeException{

	/**
	 * 序列化
	 */
	private static final long serialVersionUID = 2794289247665663373L;
	
	private ErrorCode errorCode = null;
	
	/**
	 * 构造函数
	 */
	public StreamingRuntimeException() {}
	
	/**
	 * 默认的构造函数
	 * @param message 异常消息
	 */
	public StreamingRuntimeException(String message){
		super(message);
	}
	
	/**
	 *  
	 * @param cause 异常堆栈
	 */
	public StreamingRuntimeException(Throwable cause){
		super(cause);
	}
	
	/**
	 * 
	 * @param message 异常消息
	 * @param cause 异常堆栈
	 */
	public StreamingRuntimeException(String message,Throwable cause){
		super(message,cause);
	}
	
	   /** <默认构造函数>
     *@param message 异常消息
     *@param cause 异常堆栈
     *@param enableSuppression whether or not suppression is enabled
     *                          or disabled
     *@param writableStackTrace whether or not the stack trace should
     *                           be writable
     */
    public StreamingRuntimeException(String message, Throwable cause, boolean enableSuppression,
        boolean writableStackTrace){
        super(message, cause, enableSuppression, writableStackTrace);
    }
    
    /**
     * 
     * @param code
     * @param errorArgs
     */
    public StreamingRuntimeException(ErrorCode code,String... errorArgs){
    	this(null,code,errorArgs);
    }
	
    /**
     * 
     * @param cause
     * @param code
     * @param errorArgs
     */
	public StreamingRuntimeException(Throwable cause,ErrorCode code,String... errorArgs){
		super(code.getFullMessage(errorArgs), cause);
		errorCode = code;
	}

	public ErrorCode getErrorCode() {
		return errorCode;
	}
}
